package org.blogwu.learn.designpattern.chapter18.v2;

import java.util.HashMap;
import java.util.Map;

/**
 * 促销工厂类
 *
 * @author hyf
 * @date 2019-03-24
 **/
public class PromotionFactory {
    public static Map<String, Promotion> promotionMap = new HashMap<>();

    static {
        promotionMap.put("fanxian", new FanXianPromotion());
        promotionMap.put("lijian", new LiJianPromotion());
        promotionMap.put("manjian", new ManJianPromotion());
    }

    private PromotionFactory() {

    }

    public Promotion getPromotionByKey(String name) {
        Promotion promotion = promotionMap.get(name);
        return promotion;
    }

}
